<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header">
</head>
<body class="gray-bg">

	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>活动名称：<input type="text" name="title" />
							</li>
							<li><a class="btn btn-primary btn-rounded btn-sm"
								onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm"
								onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.addFull()"
					shiro:hasPermission="jiugongge:jiugongge:add"> <i
					class="fa fa-plus fa-lg"></i> 添加
				</a> 
				<a class="btn btn-success btn-edit"
					onclick="toHtml()"
					shiro:hasPermission="jiugongge:jiugongge:edit" th:href="@{/jiugongge/jiugonggePrizes/}"> <i
					class="fa fa-gift fa-lg" aria-hidden="true"></i> 奖品设置
				</a> 
				<a class="btn btn-success btn-del"
					shiro:hasPermission="jiugongge:jiugongge:remove" th:href="@{/jiugongge/jiugonggeAwards}"> <i
					class="fa fa-tags fa-lg"></i> 奖项设置
				</a> 
				<a class="btn btn-success" onclick="$.table.exportExcel()"
					shiro:hasPermission="jiugongge:jiugongge:export"> <i
					class="fa fa-download fa-lg"></i> 导出
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('jiugongge:jiugongge:edit')}]];
        var removeFlag = [[${@permission.hasPermi('jiugongge:jiugongge:remove')}]];
        var prefix = ctx + "jiugongge/jiugongge";
        
        
        function toHtml() {
        	var addPage = layer.open({
        		type : 2,
        		title : '增加',
        		maxmin : true,
        		shadeClose : false, // 点击遮罩关闭层
        		area : [ '800px', '520px' ],
        		content : ctx + 'jiugongge/jiugonggePrizes' // iframe的url
        	});
        	layer.full(addPage);
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "九宫格活动",
                striped: false, // 是否各行渐变色
				search: false,
		        showExport: true,
                columns: [
				{
					field : 'id', 
					title : 'ID',
					visible: false
				},
				{
					field : 'title', 
					title : '活动名称',
					sortable: true
				},
				{
					field : 'starttime', 
					title : '开始时间',
					sortable: true
				},
				{
					field : 'endtime', 
					title : '结束时间',
					sortable: true
				},
				{
					field : 'count', 
					title : '抽奖次数',
					sortable: true
				},
				{
					field : 'foucsUserCanJoin', 
					title : '是否关注可参加',
					formatter: function(value, item, index) {
			                if (item.foucsUserCanJoin == '0') {
			                    return '<span class="label label-warning">否</span>';
			                }
			                else if (item.foucsUserCanJoin == '1') {
			                    return '<span class="label label-primary">是</span>';
			                }
			            }
				},
				{
					field : 'bindingMobileCanJoin', 
					title : '是否绑定手机可参加',
					sortable: true,
					formatter: function(value, item, index) {
		                if (item.bindingMobileCanJoin == '0') {
		                    return '<span class="label label-warning">否</span>';
		                }
		                else if (item.bindingMobileCanJoin == '1') {
		                    return '<span class="label label-primary">是</span>';
		                }else{
		                	return '<span class="label label-default">未定义</span>';
		                }
		            }
				},
				{
					field : 'numPerDay', 
					title : '每日抽奖次数',
					sortable: true
				},
				{
					field : 'prizeStatus', 
					title : '是否中奖可参与',
					sortable: true,
					formatter: function(value, item, index) {
		                if (item.prizeStatus == '0') {
		                    return '<span class="label label-primary">中奖可继续参与</span>';
		                }
		                else if (item.prizeStatus == '1') {
		                    return '<span class="label label label-warning">中奖不可继续参与</span>';
		                }
		                else {
		                	return '<span class="label label-default">未定义</span>';
		                }
		            }
				},
				{
					field : 'joinNumLimit', 
					title : '参与总人数',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
                    valign: 'center',
                    width : '20%',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-cog"></i>高级配置</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-tag"></i>抽奖记录</a><br/><br/>');
                        actions.push('<a class="btn btn-primary btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-user-circle"></i>审核员管理</a> ');                   
                        actions.push('<a class="btn btn-warning btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa fa-tag"></i>中奖记录</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-share-alt"></i>活动链接</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>